/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template sigFile, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.ac.iie.di.server;

import cn.ac.iie.di.global.GlobalParas;
import cn.ac.iie.di.bcps.JsonBcpsSender;
import cn.ac.iie.di.bcps.RetryTask;
import cn.ac.iie.di.splitor.JsonSplitor;
import cn.ac.iie.di.splitor.UngzipSplitor;
import cn.ac.iie.di.ungzip.UngzipHandler;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

/**
 *
 * @author lenovo-pc
 */
public class MMsParserStartup {

    static Logger logger = null;

    static {
        PropertyConfigurator.configure(ClassLoader.getSystemClassLoader().getResource("log4j.properties"));
        logger = Logger.getLogger(MMsParserStartup.class.getName());
    }

    public static void main(String[] args) {
        startunGzFile();
        startGzSplitor();
        startBcpsSender();
        startJsonSplitor();
    }

    public static void startBcpsSender() {
        for (int i = 0; i < 1; i++) {
            Thread thread = new Thread(new JsonBcpsSender());
            thread.setName("JsonBcpsSender" + "_" + i);
            thread.start();
        }
        Thread t = new Thread(new RetryTask());
        t.setName("RetryTask");
        t.start();

    }

    public static void startunGzFile() {
        for (int i = 0; i < 1; i++) {
            Thread thread = new Thread(new UngzipHandler());
            thread.setName("unGzBcps" + "_" + i);
            thread.start();
        }
    }

    public static void startGzSplitor() {
        Thread thread = new Thread(new UngzipSplitor(GlobalParas.ORI_NEWS, GlobalParas.FILE_NEWS));
        thread.setName("JsonGz" + "_bcps");
        thread.start();
    }

    public static void startJsonSplitor() {
        for (int i = 0; i < 3; i++) {
            Thread thread = new Thread(new JsonSplitor(GlobalParas.TMP_NEWS, GlobalParas.FILE_NEWS, GlobalParas.newsQueue));
            thread.setName("JsonSplitor" + "_bcps " + i);
            thread.start();
        }

    }

}
